package com.liu.voluntary.util;


//校验用户输入    正则表达式

import org.junit.Test;
import org.springframework.util.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidatorUtil {

//    手机号的正则表达式
    private static final Pattern mobile_pattern = Pattern.compile("^[1][3-9][0-9]{9}$");


    public static boolean isMobile(String mobile){

        if (!StringUtils.hasText(mobile)){
            return false;
        }

        //进行校验
        Matcher matcher = mobile_pattern.matcher(mobile);
        return matcher.matches();

    }

    @Test
    public void t1(){

        String s = "12345678911";
        System.out.println(isMobile(s));
    }


}
